// 类可以包含字段、构造函数和方法, 默认的作用域是public ，其他可用的是protected 和 private
class Person {

    name:string;

    static age: number = 18

    constructor(name:string) {
        this.name = name;
    }

    disp(): void {
        console.log(this.name)
    }
}

var person = new Person("zhangsan");
// 调用方法
person.disp();
// 读取属性
console.log(person.name)

// 支持单继承，不支持多继承，但可以多重继承,可以重写方法
class Girl extends Person {
    sayHi() : void {
        console.log("I' m girl")
    }
}

class Mom extends Girl {
    sayHi(): void {
        super.sayHi();
        console.log("i' m mom")
    }
}

var mom = new Mom("san")
mom.sayHi();

// 使用implements可以实现接口，同java
class Dad implements IPerson {
    firstName: string;
    lastName: string;

    constructor(firstName:string, lastName:string) {
        this.firstName = firstName;
        this.lastName = lastName;
    }

    sayHi():string {
        return "hello";
    }
}

var dad :Dad = new Dad("zhang","san");
console.log(dad.sayHi());